#ifndef __VLOG_LOGGER_H__
#define __VLOG_LOGGER_H__

#include "appender/filelogappender.h"
#include "appender/logappender.h"
#include "appender/stdcoutappender.h"
#include "logevent.h"
#include <iostream>
#include <list>
#include <memory>
#include <string>
#include <string_view>

namespace vlog
{

namespace event
{
class LogEvent;
} // namespace event

class Logger
{
    public:
    using ptr = std::shared_ptr<Logger>;

    public:
    explicit Logger(const std::string_view& logName = "default");
    ~Logger();

    const std::string GetLogName() const noexcept
    {
        return m_logName;
    }

    void SetLogLevel(const LogLevel::Level& level) noexcept
    {
        m_logLevel = level;
    }

    const LogLevel::Level& GetLogLevel() const noexcept
    {
        return m_logLevel;
    }

    void AddLogAppender(const LogAppender::ptr logAppender) noexcept;
    void DelLogAppender(const LogAppender::ptr logAppender) noexcept;
    void ClearLogAppender() noexcept;

    void WriteLog(event::LogEvent::ptr logEvent) noexcept;

    const Logger& operator<<(const std::string& str) const;
    const Logger& operator<<(const char* str) const;

    private:
    std::string m_logName;
    LogLevel::Level m_logLevel;
    std::list<LogAppender::ptr> m_logAppenders;
};

} // namespace vlog

#endif